// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.ooops;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

/**
 * Default implementation of {@code ClassDataSupplier} loading class data from
 * current directory.
 * 
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class FileClassDataSupplier implements ClassDataSupplier {

  public byte[] loadClassData(String className) {
    try {
      InputStream file = new FileInputStream(className.replace('.', '/') + ".class");
      return IOUtils.toByteArray(file);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
